package com.myblog.demo.common;

/**
 * 验证用户名和密码的合法性，即只能是数字或者字母
 */
public class UserAuthenticationTools {
    public static boolean isValidCredentials(String username, String password) {
        if (username == null || password == null) {
            return false;
        }

        // 判断用户名和密码是否只包含数字和字母
        boolean isUsernameValid = username.matches("^[a-zA-Z0-9]+$");
        boolean isPasswordValid = password.matches("^[a-zA-Z0-9]+$");

        return isUsernameValid && isPasswordValid;
    }
}
